package com.yellowpage.bigdata.service;

import com.yellowpage.bigdata.dao.NspOnofflogTaRegionTypeDayEntityDao;
import com.yellowpage.bigdata.data.NspOnofflogTaRegionTypeDayEntity;
import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;

import java.util.List;
import java.util.Map;

public class NspOnofflogTaRegionTypeDayEntityServiceImpl extends BaseServiceImpl implements NspOnofflogTaRegionTypeDayEntityService {
	  private NspOnofflogTaRegionTypeDayEntityDao nspOnofflogTaRegionTypeDayEntityDao;
	
	  public void setNspOnofflogTaRegionTypeDayEntityDao(NspOnofflogTaRegionTypeDayEntityDao nspOnofflogTaRegionTypeDayEntityDao) {
		  this.nspOnofflogTaRegionTypeDayEntityDao = nspOnofflogTaRegionTypeDayEntityDao;
	  }
	
	
	  /* Smooth generate Method */ 
	  public NspOnofflogTaRegionTypeDayEntity getNspOnofflogTaRegionTypeDayEntity(Long id){
	      return nspOnofflogTaRegionTypeDayEntityDao.get(id);
	  }
	  
    public List<NspOnofflogTaRegionTypeDayEntity> getAllNspOnofflogTaRegionTypeDayEntity(){
        return nspOnofflogTaRegionTypeDayEntityDao.getAll();
    }
    
    public List<Map> queryNspOnofflogTaRegionTypeDayEntityByPage(Map queryMap, PageRender pageRender) {
		String t2 = queryMap.get("regionCode").equals("()") ? "" :  " and b.SHORT_NAME in "+queryMap.get("regionCode");
		QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(
				"SELECT a.NOTE , a.CREATE_TIME ,  a.IMEI_DAY_COUNT , a.IMEI_ALL_COUNT , a.IMEI_NEW_COUNT , a.LOG_DATE , a.REGION_CODE , " +
						"a.TYPE , a.CREATE_USER, b.SHORT_NAME as REGION_NAME " +
						"FROM NSP_ONOFFLOG_TA_REGION_TYPE_DAY a, OMC_REGION b WHERE 1=1 AND  b.REGION_CODE = a.REGION_CODE " + t2)
				.addCondition(" and a.LOG_DATE >= :logDate ")
				.addCondition(" and a.LOG_DATE <= :query_logDate_end ")
				.addCondition(" and a.TYPE = :query_type ")
				;


		List<Map> resultList;

		if (pageRender != null)
		{ resultList = sqlAssistant.queryByPage(
				baseDao.getConnection(), queryMap, pageRender);}


		else

		{ resultList = sqlAssistant.query(
				baseDao.getConnection(), queryMap);}


		return resultList;
	}
    
    
    public void saveNspOnofflogTaRegionTypeDayEntity(NspOnofflogTaRegionTypeDayEntity nspOnofflogTaRegionTypeDayEntity){
        nspOnofflogTaRegionTypeDayEntityDao.save(nspOnofflogTaRegionTypeDayEntity);
    }
    
	  public void updateNspOnofflogTaRegionTypeDayEntity(NspOnofflogTaRegionTypeDayEntity nspOnofflogTaRegionTypeDayEntity){
	      nspOnofflogTaRegionTypeDayEntityDao.update(nspOnofflogTaRegionTypeDayEntity);
	  }
	  
	  public void delete(List deleteList){
	      nspOnofflogTaRegionTypeDayEntityDao.remove(deleteList);
	  }
	  
	  
	 
	
}	